<?php
 
require_once('../../../../wp-config.php');
require_once('../../../../wp-includes/functions.php');

global $table_prefix, $wpdb, $post;
$integration = $wpdb->prefix."integration";

$rating = $_REQUEST['rating'];
$userid = $_REQUEST['userid'];
$username = $_REQUEST['username'];
$postid = $_REQUEST['postid'];
$date=date("Y-m-d H:i:s");

$result = $wpdb->get_results("SELECT time FROM $integration WHERE userid =".$userid."");

if(empty($result))
{
        $sql="INSERT INTO $integration (userid, username, postid, time) VALUES ('" .$userid. "','".$username. "','" .$postid. "','" . $date. "')";
        $r = mysql_query($sql);
        if($r)
        {
            add_post_meta($postid, '_integration',0,true);
            $collect_count = get_post_meta($postid, '_integration', true);
            if($collect_count != null)
            {
                $collect_count = $collect_count+5;
                update_post_meta($postid, '_integration', $collect_count);
            }
            echo $collect_count.'1';    
        }
        else
        {
            echo '数据存储失败';
            
        } 
}
else
{
   echo '已评分';
}
?>